package com.servlet.request1; /**
 * @author wzm
 * @create 2023-11-06 11:26
 * project_name:web2310
 * @Description
 */

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;

@WebServlet("/win1")
public class Win1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doPost(request, response);//调用doPost
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("你好，欢迎光临，我做了一些事情，接下来你去窗口2");
        //设置需要跳转的路径
        //RequestDispatcher dispatcher = request.getRequestDispatcher("/win2");
        //跳转到窗口2
        //dispatcher.forward(request,response);

        //开票
        //向request中存储数据 key-vale
        request.setAttribute("piao","门诊缴费小票150");


        //直接写
        //request.getRequestDispatcher("/win2").forward(request,response);
        //测试访问服务器以外的资源
        //request.getRequestDispatcher("http://www.baidu.com").forward(request,response);
        // /:http://localhost:8080/web04/WEB-INF/form.html
        //转发是可以访问受保护的WEB-INF路径的
        request.getRequestDispatcher("/WEB-INF/form.html").forward(request,response);

    }
}
